package converter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import repository.EventRepository;
import domain.Event;

@Component
public class EventConverter implements Converter<String, Event>{
	
	private EventRepository eventRepository;
	
	@Autowired
	public EventConverter(EventRepository eventRepository) {
		this.eventRepository = eventRepository;
	}

	@Override
	public Event convert(String source) {
		return eventRepository.get(Integer.valueOf(source));
	}

}
